package com.eastcom.bm.dataprocess.noticeserver;

import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;

import com.eastcom.canicula.stope.utils.MyLogger;

public class EmailMessage extends AlarmMessage{

	private String indicatoruuid;
	
	private String timestamp;
	
	private String slauuid;
	
	private String modelmessgae;
	
	private String receiver;

	private String subject;
	
	private String sendMessage;
	
	private Map<String,String> paramMap=new HashMap<String,String>();
	
	public EmailMessage(){
		
	}
	
	public EmailMessage(Map parammap){
		this.paramMap=parammap;
		this.parseContentinfo(parammap);
	}
	
	private void parseContentinfo(Map contentInfo){		
		Iterator it=contentInfo.entrySet().iterator();
		
	}
	
	public String makeComment()
    {
        String result = null;
        
        result = this.getSendMessage();
        if(result==null || result.equals(""))
        {
            result = this.getModelmessgae();
            
            if(result==null || result.equals(""))
            {
                MyLogger.logger.warn("MESSAGE is null in SORF for uuid "+this.getUuid() +", and FM won't send email for message @"+this);
         		return null;
            }else
            {	
            	Map var = this.paramMap;
            	if(var!=null)
            	{
            	    for(Iterator it = var.keySet().iterator(); it.hasNext();)
            	    {
            	        String name = (String)it.next();
            	        String value = (String)var.get(name);
            	        result = result.replaceAll("(\\$"+name+")",value);
            	    }
            	}
            }
        }

        this.sendMessage=result;
        
        return result;
    }
	
	public Object setParam(String key,String value){
		return paramMap.put(key, value);
	}
	
	public Object getParam(String name){
		return paramMap.get(name);
	}
	
	public String getReceiver() {
		return receiver;
	}

	public void setReceiver(String receiver) {
		this.receiver = receiver;
	}

	public String getSubject() {
		return subject;
	}

	public void setSubject(String subject) {
		this.subject = subject;
	}

	public String getModelmessgae() {
		return modelmessgae;
	}

	public void setModelmessgae(String modelmessgae) {
		this.modelmessgae = modelmessgae;
	}

	public String getSendMessage() {
		return sendMessage;
	}

	public void setSendMessage(String sendMessage) {
		this.sendMessage = sendMessage;
	}

	public String getIndicatoruuid() {
		return indicatoruuid;
	}

	public void setIndicatoruuid(String indicatoruuid) {
		this.indicatoruuid = indicatoruuid;
	}

	public String getSlauuid() {
		return slauuid;
	}

	public void setSlauuid(String slauuid) {
		this.slauuid = slauuid;
	}

	public String getTimestamp() {
		return timestamp;
	}

	public void setTimestamp(String timestamp) {
		this.timestamp = timestamp;
	}

	public Map<String, String> getParamMap() {
		return paramMap;
	}

	public void setParamMap(Map<String, String> paramMap) {
		this.paramMap = paramMap;
	}

}
